﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Classes {
    import flash.display.*;
    import org.aswing.*;
    import com.greensock.*;
    import flash.text.*;
    import Display.aswingui.*;
    import Engine.*;

    public class SimpleProgressBar extends JPanel {

        protected var m_animTimeline:TimelineLite;
        protected var m_bgAlpha:Number = 0;
        protected var m_outlineAlpha:Number = 1;
        protected var m_titleColor:uint;
        protected var m_barColor:uint;
        protected var m_bgColor:uint;
        protected var m_outlineColor:uint;
        protected var m_barFlashColor:uint = 0xFFFFFF;
        protected var m_titleLabel:JLabel;
        protected var m_title:String;
        protected var m_ratioLabel:JLabel;
        protected var m_ratio:String;
        protected var m_progress:Number = 0;
        protected var m_barContainer:JPanel;
        protected var m_barInnerContainer:JPanel;
        protected var m_barAssetPane:AssetPane;
        protected var m_barOutline:Sprite;
        protected var m_barBg:Sprite;
        protected var m_barFlash:Sprite;
        protected var m_barHolder:Sprite;
        protected var m_barMask:Sprite;
        protected var m_bar:Sprite;
        protected var m_barWidth:Number;
        protected var m_barHeight:Number;
        protected var m_barCornerRounding:Number;
        protected var m_barX:Number = 4;
        protected var m_barY:Number = 0;
        protected var m_gap:Number = 3;
        protected var m_bottomOffset:Number = 3;

        public function SimpleProgressBar(_arg1:uint, _arg2:uint, _arg3:Number, _arg4:Number, _arg5:Number=0, _arg6:Number=0){
            super(new SoftBoxLayout(SoftBoxLayout.Y_AXIS, 0, SoftBoxLayout.LEFT));
            var _local7:ASFont = new ASFont(EmbeddedArt.DEFAULT_FONT_NAME_BOLD, 14, false, false, false, new ASFontAdvProperties(true, AntiAliasType.ADVANCED, GridFitType.PIXEL));
            var _local8:ASColor = new ASColor(_arg1);
            this.m_bar = new Sprite();
            this.m_barBg = new Sprite();
            this.m_barMask = new Sprite();
            this.m_barFlash = new Sprite();
            this.m_barHolder = new Sprite();
            this.m_barOutline = new Sprite();
            this.m_barContainer = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0, false));
            this.m_barAssetPane = new AssetPane();
            this.m_titleLabel = new JLabel("", null, JLabel.LEFT);
            this.m_titleLabel.setFont(_local7);
            this.m_titleLabel.setForeground(_local8);
            this.m_ratioLabel = new JLabel("", null, JLabel.LEFT);
            this.m_ratioLabel.setFont(_local7);
            this.m_ratioLabel.setForeground(_local8);
            this.m_titleColor = _arg1;
            this.m_bgColor = _arg1;
            this.m_outlineColor = _arg1;
            this.m_barColor = _arg2;
            this.m_barCornerRounding = _arg5;
            this.m_barWidth = _arg3;
            this.m_barHeight = _arg4;
            this.m_gap = _arg6;
            this.m_barMask.graphics.beginFill(this.m_bgColor);
            this.m_barMask.graphics.drawRoundRect(this.m_barX, this.m_barY, this.m_barWidth, (this.m_barHeight + 2), this.m_barCornerRounding, this.m_barCornerRounding);
            this.m_barMask.graphics.endFill();
            this.m_barFlash.alpha = 0;
            this.m_bar.mask = this.m_barMask;
            this.m_barBg.mask = this.m_barMask;
            this.m_barHolder.addChild(this.m_barMask);
            this.m_barHolder.addChild(this.m_barBg);
            this.m_barHolder.addChild(this.m_bar);
            this.m_barHolder.addChild(this.m_barFlash);
            this.m_barHolder.addChild(this.m_barOutline);
            this.m_barAssetPane.setAsset(this.m_barHolder);
            this.m_barAssetPane.setPreferredWidth((this.m_barHolder.width + 9));
            this.m_barAssetPane.setPreferredHeight((this.m_barHolder.height + 1));
            this.m_barContainer.append(this.m_barAssetPane);
            this.m_barContainer.append(this.m_ratioLabel);
            this.append(this.m_titleLabel);
            this.append(ASwingHelper.verticalStrut(this.m_gap));
            this.append(this.m_barContainer);
            this.setProgress(0);
        }
        public function setTitle(_arg1:String):void{
            if (_arg1 != this.m_title){
                this.m_title = _arg1;
                this.m_titleLabel.setText(this.m_title);
                ASwingHelper.prepare(this);
            };
        }
        public function setTitleColor(_arg1:uint):void{
            this.m_titleLabel.setForeground(new ASColor(_arg1));
        }
        public function setOutlineColor(_arg1:uint):void{
            this.m_outlineColor = _arg1;
            this.setProgress(this.m_progress);
        }
        public function setBgColor(_arg1:uint):void{
            this.m_bgColor = _arg1;
            this.setProgress(this.m_progress);
        }
        public function setFilters(_arg1:Array):void{
            this.m_titleLabel.setTextFilters(_arg1);
        }
        public function setBgAlpha(_arg1:Number):void{
            this.m_bgAlpha = _arg1;
            this.setProgress(this.m_progress);
        }
        public function setOutlineAlpa(_arg1:Number):void{
            this.m_outlineAlpha = _arg1;
            this.setProgress(this.m_progress);
        }
        public function setProgressRatioText(_arg1:String):void{
            if (this.m_ratio != _arg1){
                this.m_ratio = _arg1;
                this.m_ratioLabel.setText(this.m_ratio);
                ASwingHelper.prepare(this);
            };
        }
        public function setProgressRatio(_arg1:Number, _arg2:Number):void{
            var _local3:Number = MathUtil.clamp((_arg1 / _arg2), 0, 1);
            this.setProgress(_local3);
            var _local4:String = String(((_arg1 + "/") + _arg2));
            this.setProgressRatioText(_local4);
        }
        public function setProgress(_arg1:Number):void{
            this.m_bar.graphics.clear();
            this.m_barOutline.graphics.clear();
            this.m_barBg.graphics.clear();
            this.m_barFlash.graphics.clear();
            this.m_progress = MathUtil.clamp(_arg1, 0, 1);
            this.m_barOutline.graphics.lineStyle(2, this.m_outlineColor, this.m_outlineAlpha);
            this.m_barOutline.graphics.drawRoundRect(this.m_barX, (this.m_barY + 1), this.m_barWidth, this.m_barHeight, this.m_barCornerRounding, this.m_barCornerRounding);
            this.m_barBg.graphics.beginFill(this.m_bgColor, this.m_bgAlpha);
            this.m_barBg.graphics.drawRoundRect(this.m_barX, (this.m_barY + 1), this.m_barWidth, this.m_barHeight, this.m_barCornerRounding, this.m_barCornerRounding);
            this.m_barBg.graphics.endFill();
            this.m_bar.graphics.beginFill(this.m_barColor);
            this.m_bar.graphics.drawRect(this.m_barX, (this.m_barY + 1), (this.m_progress * this.m_barWidth), this.m_barHeight);
            this.m_bar.graphics.endFill();
            this.m_barFlash.graphics.beginFill(this.m_barFlashColor);
            this.m_barFlash.graphics.drawRect(this.m_barX, (this.m_barY + 1), (this.m_progress * this.m_barWidth), this.m_barHeight);
            this.m_barFlash.graphics.endFill();
        }
        public function setProgressBarFlash(_arg1:Number=2, _arg2:Number=0.5, _arg3:uint=0xFFFFFF):void{
            this.m_barFlashColor = _arg3;
            this.setProgress(this.m_progress);
            var _local4:Array = [];
            var _local5:Number = (_arg2 / 2);
            var _local6:int = int((_arg1 / _arg2));
            var _local7:int;
            while (_local7 < _local6) {
                _local4.push(new TweenLite(this.m_barFlash, _local5, {alpha:1}));
                _local4.push(new TweenLite(this.m_barFlash, _local5, {alpha:0}));
                _local7++;
            };
            if (this.m_animTimeline){
                this.m_animTimeline.kill();
                this.m_barFlash.alpha = 0;
            };
            this.m_animTimeline = new TimelineLite();
            this.m_animTimeline.appendMultiple(_local4, 0, TweenAlign.SEQUENCE);
        }

    }
}//package Classes 
